<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<script type="text/javascript" src="/fuman/js/product.js"></script>

<title>编辑主商品信息</title>
<script language="javascript">
//$.validator.setDefaults({
//    submitHandler: function() {
//      $("#otherForm").submit();
//    }
//});
$().ready(function() {
	$("#sku").focus();
    $("#otherForm").validate();
	{{if $addgoodsno}}
	$("#goodstypeID").val(7);
	showinput('{{$addgoodsno}}');
	{{/if}}
	getsecondcate('{{$goods.p_secondclassid}}');
	
	getthirdcate('{{$goods.p_secondclassid}}','{{$goods.p_threeclassid}}');
});



$.validator.setDefaults({
  submitHandler: function(form) { form.submit(); }
});
function JqValidate()  
{  
    return $( '#otherForm' ).validate();  
}

function submitBtn()  
{  
     if( JqValidate()){ 
	 //	alert(1);
         $( '#otherForm' ).submit();  
    }  
}  

function issupplier()
{
	var supplier = $("#supplier").val();
	if(supplier == 3)
	{
		$("#showsupplier").show();
	}else{
		$("#showsupplier").hide();	
	}
}

</script>
<body class="withvernav">
<div class="bodywrapper"> {{include file='/public/leftmenu.tpl'}}
  <div class="centercontent">
    <div class="pageheader notab">
      <h1 class="pagetitle">编辑主商品信息</h1>
      <span class="pagedesc"></span>
      <div class="menulist">
        <ul class="profile_summary">
          <li class="current"><a href="/product/productlist">产品列表</a></li>
        </ul>
      </div>
    </div>
    <!--pageheader-->
    
    <div id="contentwrapper" class="contentwrapper">
      <div id="basicform" class="subcontent">
        <form class="stdform stdform2"  id="otherForm" method="post" action="/product/saveParentProduct" enctype="multipart/form-data">
        <input type="hidden" name="parentID" value="{{$goods.p_parent_id}}">
         <input type="hidden" name="saveparent" value="1">
          <table cellpadding="0" cellspacing="0" border="0" class="stdtable">
            <thead>
              <tr>
                <th colspan="2" class="head1">一、基础信息</th>
              </tr>
            </thead>
          </table>
          <table cellpadding="0" cellspacing="0" border="0" class="stdtable">
            <tbody>
              <tr>
                <td class="head1" width="120">商品分类 *</td>
                <td class="head0" colspan="3"><select name="bigclassID" id="bigclassID" class="selection" style="width:200px;" onChange="getsecondcate()" required>
                    <option value="">请选择</option>
                    {{foreach from=$categorylist item=res key=key}}
                    <option value="{{$res.id}}" {{if $goods.p_bigclassid == $res.id}} selected{{/if}}>{{$res.cate_name}}</option>
                    {{/foreach}}
                  </select>
                &nbsp; <span id="showsecondcate"></span> &nbsp; <span id="showthirdcate"></span></td>
              </tr>
               <tr>
                <td class="head1">商品SKU *</td>
                <td colspan="3" class="head0"><input type="text" name="sku" id="sku" class="width200" value="{{$goods.p_parent_sku}}" onKeyUp="this.value=this.value.replace(/[^\w_\w-]/g,'');" required style="text-transform:uppercase;" readonly>
                <input type="hidden" id="autolikesku" name="autolikesku" value="{{$autolikesku}}">
                <input type="hidden" id="yaautolikesku" name="yaautolikesku" value="{{$yaautolikesku}}">
                
               {{if $factorygoodsku==1}}
               自动生成:
               	 &nbsp;&nbsp;<a href="#" onClick="autosku(1)"><font color="red">[<B>通用关联SKU</B>]</font></a>
                 &nbsp;&nbsp;<a href="#" onClick="autosku(2)"><font color="blue">[<B>欧版关联（男款）</B>]</font></a>
                  &nbsp;&nbsp;<a href="#" onClick="autosku(5)"><font color="blue">[<B>欧版关联（女款）</B>]</font></a>
                  &nbsp;&nbsp;<a href="#" onClick="autosku(3)"><font color="red">[<B>亚版关联（男款）</B>]</font></a>
                  &nbsp;&nbsp;<a href="#" onClick="autosku(4)"><font color="red">[<B>亚版关联（女款）</B>]</font></a>
               {{/if}}
                 <span id="skuerr"></span></td>
              </tr>
               <tr>
                <td class="head1">商品名称</td>
                <td colspan="3" class="head0"><input type="text" name="goods_name" class="width400" value="{{$goods.p_parent_name}}" required></td>
              </tr>
              <tr>
                <td class="head1">英文名称</td>
                <td colspan="3" class="head0"><input type="text" name="en_goods_name" class="width400" value="{{$goods.p_en_goods_name}}"></td>
              </tr>
              
              <tr>
                <td class="head1" width="10%">重量(克)</td>
                <td class="head0" width="40%"><input type="text" name="weight" class="width100" value="{{$goods.p_weight}}"></td>
                <td class="head0" width="120">成本价格（元）</td>
                <td class="head1"><input type="text" name="costprice" id="costprice" class="width100" value="{{$goods.p_costprice}}" required ></td>
              </tr>
               <tr>
                <td class="head1">关联价</td>
                <td class="head0"><input type="text" name="bulkprice" id="bulkprice" class="width100" value="{{$goods.bulkprice}}" onBlur="changbulkpricememo({{$goods.goods_id}},{{$goods.bulkprice}})">
                <span id="bulkpricepricememo"></span></td>
                <td class="head0" width="120">工时</td>
                <td class="head1">
                <input type="text" name="wages" class="width100" value="{{$goods.wages}}" >（元）
              </td>
              </tr>
               <tr>
                <td class="head1"><span class="head0">销售状态</span></td>
                <td class="head0" width="30%"><span class="head1">
                    {{foreach from=$salestatus item=res key=key}}
                    {{if $goods.status ==$res}}  <input type="hidden" name="sale_status" value="{{$key}}"> {{$res}}{{/if}}
                    {{/foreach}}
                  
                 <!-- {{if $managers || in_array('258',$showpower)}}
                <select class="selectCss2" name="sale_status" id="sale_status" required>
                    <option value="">请选择</option>
                    {{foreach from=$salestatus item=res key=key}}
                    <option value="{{$key}}" {{if $goods.status ==$res}} selected{{/if}}> {{$res}} </option>
                    {{/foreach}}
                   
                  
                  </select>
                 {{else}}
                       {{foreach from=$salestatus item=res key=key}}
                    {{if $goods.status ==$res}}  <input type="hidden" name="sale_status" value="{{$res}}"> {{$res}}{{/if}}
                    {{/foreach}}
                  {{/if}}-->
                  
                  
                </span></td>
                <td class="head0" width="120"><span class="head1">商品属性 </span></td>
                <td class="head1"><span class="head0">
                  <select name="goodstypeID" id="goodstypeID" class="selection" style="width:200px;" onChange="cleart()" >
                    <option value="">请选择</option>
                    
                    
                    {{foreach from=$attribute item=res key=key}}
                    
                    
                    <option value="{{$res.cat_id}}" {{if $goods.p_goodstypeID == $res.cat_id}} selected{{/if}}>{{$res.cat_name}}</option>
                    
                    
                    {{/foreach}}
                  
                  
                  </select>
                </span></td>
              </tr>
              
                <tr>
                  <td class="head1">采购员</td>
                  <td class="head0"><select name="buyer" id="buyer" class="selection select2_group" style="width:200px;"  required>
                    <option value="">请选择</option>
                    
                      {{foreach from=$userlist item=res key=key}}
                    
                    <option value="{{$res.name}}" {{if $goods.p_buyer == $res.name}} selected{{/if}}>{{$res.name}}</option>
                    
                    {{/foreach}}
                  
                  </select></td>
                  <td class="head1">开发人员 </td>
                <td class="head0"><select name="checkman" id="checkman" class="selection select2_group" style="width:200px;" required>
                    <option value="">请选择</option>
                    
                    {{foreach from=$userlist item=res key=key}}
                    
                    <option value="{{$res.name}}" {{if $goods.p_checkman == $res.name}} selected{{/if}}>{{$res.name}}</option>
                    
                    {{/foreach}}
                  
                  </select></td>
                </tr>
                
                
              <tr>
                <td class="head1">供货商</td>
                <td class="head0"><select name="supplier" id="supplier" class="selection" style="width:200px;"  onChange="issupplier()" >
                  <option value="">请选择</option>
                  
                    {{foreach from=$factory item=res key=key}}
                    
                  <option value="{{$res.id}}" {{if $res.id == $goods.p_supplier}} selected{{/if}}>{{$res.name}}</option>
                  
                    {{/foreach}}
                  
                  
                </select></td>
                <td class="head1">申报价值(元)</td>
                <td class="head0"><input type="text" name="pd_declare_value" class="width100" value="{{$goods.p_pd_declare_value}}" ></td>
              </tr>
             
               
               <tr>
                <td class="head1">采购天数</td>
                <td class="head0"><input type="text" name="procurement" class="width100" value="{{$goods.p_procurement}}"></td>
                <td class="head0" width="120">零售价格（元）</td>
                <td class="head1"><input type="text" name="sellprice" class="width100" value="{{$goods.p_sellprice}}"></td>
              </tr>
                <tr>
                <td class="head1">商品品牌</td>
                <td class="head0"><input type="text" name="goods_brand" class="width100" value="{{$goods.p_goods_brand}}"></td>
                <td class="head0" width="120">库存警戒天数</td>
                <td class="head1"><input type="text" name="inventory_day" class="width100" value="{{$goods.p_inventory_day}}" onKeyUp="this.value=this.value.replace(/[^0-9]/g,'');"></td>
              </tr>
                
                <tr>
                <td class="head1">质检标准</td>
                <td class="head0" colspan="3">
                    <link rel="stylesheet" href="/fuman/kindeditor/themes/default/default.css" />
	<link rel="stylesheet" href="/fuman/kindeditor/plugins/code/prettify.css" />
	<script charset="utf-8" src="/fuman/kindeditor/kindeditor.js"></script>
	<script charset="utf-8" src="/fuman/kindeditor/lang/zh_CN.js"></script>
	<script charset="utf-8" src="/fuman/kindeditor/plugins/code/prettify.js"></script>
	<script>
		KindEditor.ready(function(K) {
			 window.editor = K.create("#standard");
		});
	</script>
	<textarea id="standard" name="standard" style="width:85%;height:300px;visibility:hidden;">{{$goods.standard}}</textarea>
                </td>
                 <tr>
                <td class="head1">面料信息</td>
                <td class="head0" colspan="3">
                <textarea name="fabricinfo" cols="10" rows="6">{{$goods.fabricinfo}}</textarea>
                </td>
              </tr>
              </tr>
               <tr>
                <td class="head1">备注信息</td>
                <td class="head0" colspan="3">
                <textarea name="memo" cols="10" rows="6">{{$goods.memo}}</textarea>
                </td>
              </tr>
              
             </tbody>
           </table>
           
             <br>
        {{if $goods.p_supplier==3}}
         <table cellpadding="0" cellspacing="0" border="0" class="stdtable" {{if $goods.p_supplier !=3}} style="display:none"{{/if}} id="showsupplier">
            <thead>
              <tr>
                <th colspan="6" class="head1">外采购供应商 &nbsp;&nbsp;<span style="margin-top:10px"><a href="javascript:void(0)"  onClick="showinputPro()"><img src="/fuman/images/add.png"></a></span></th>
              </tr>
            </thead>
            
             <tr>       
               <td class="head1">采购商家名称</td>
                <td class="head0"><input id="businessman" name="businessman" class="width200" type="text"  value="{{$goods.businessman}}"></td>
                <td class="head0">采购连接</td>
                <td class="head1" colspan="2"><input id="businessmanline" name="businessmanline" class="width400"  value="{{$goods.businessmanline}}" type="text" ></td>
              </tr>
             
            <tbody id="showsuppliertd">
            </tbody>
          </table>
        {{/if}}
          
       
        
          <table cellpadding="0" cellspacing="0" border="0" class="stdtable">
            <thead>
              <tr>
                <td><button type="button" class="btn btn-primary" onClick="saveform()" > 保存商品 </button>
               
                 </td>
              </tr>
           
            </tbody>
          </table>
        </form>
        <br />
      </div>
      <!--subcontent--> 
      
      <!--subcontent--> 
      
    </div>
    <!--contentwrapper--> 
    
  </div>
  <!-- centercontent --> 
  
</div>
<!--bodywrapper-->
<script language="javascript">

function saveform()
{
	var costprice = $("#costprice").val();
	if(costprice=='' || costprice =='0.00')
	{
		alert("请填写成本价");
		return;	
	}
	var contenthtml = editor.html();
	editor.sync();
	$("#otherForm").submit();
}

</script>
</body>
</html>